package com.xnck.example.jertest.util;

import com.xiaoleilu.hutool.CharsetUtil;
import com.xiaoleilu.hutool.Setting;

public class ConfigUtil {

    private final static String configPath = "config.setting";
    private static Setting setting;

    public static String getValue(String key){
        if (null == setting){
            initSetting();
        }
        System.out.println("key:" + key + ";value:" + setting.getString(key));
        return setting.getString(key);
    }

    public static int getIntValue(String key){
        if (null == setting){
            initSetting();
        }
        System.out.println("key:" + key + ";value:" + setting.getString(key));
        return setting.getInt(key, 0);
    }

    private static synchronized void initSetting(){
        if (null == setting){
            setting = new Setting(configPath, CharsetUtil.UTF_8, true);
        }
    }
}
